package net.seninp.fdata.data;

import java.util.HashMap;
import java.util.Iterator;

public class Months implements Iterable<Month> {

  private HashMap<Integer, Month> months;

  public Months() {
    this.months = new HashMap<Integer, Month>();
  }

  public void add(Measurement m) {
    if (!months.containsKey(m.getMonth())) {
      months.put(m.getMonth(), new Month(m.getMonth()));
    }
    months.get(m.getMonth()).add(m);

  }

  public int size() {
    return this.months.size();
  }

  public int measurementsCount() {
    int count = 0;
    for (Month m : this.months.values()) {
      count = count + m.measurementsCount();
    }
    return count;
  }

  @Override
  public Iterator<Month> iterator() {
    return this.months.values().iterator();
  }

  public Month get(int m) {
    return this.months.get(m);
  }

}
